<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul li{
            display: flex;
            flex-direction: row;
            align-items: center;
            height: 20px;
            margin-bottom: 15px;
        }
        ul button {
            margin-left: 20px;
        }
    </style>
</head>
<body>
    <div id="app">
        <ul>
            <li v-for="item in list" :key="item" >
                <p>{{ item }}</p>
                <button @click="delData(item)">删除</button>
            </li>
        </ul>
        <button @click="addData">生成</button>
    </div>
    <script src="../vue.js"></script>
    <script>
        const app = new Vue({
            el:'#app',
            data:{
                list:[4,3,2,6,8,1,15,16,17,14]
            },
            methods:{
                addData(){
                    this.list.push(~~(Math.random()*21))
                },
                delData(i){
                    this.list = this.list.filter(item=>item !== i)
                }
            }
        })
    </script>
</body>
</html>